<?php

/*操作删除*/
        if(!empty($_GET['id'])){

            $id = $_GET['id'];

             /*编写查询语句*/
             $sql = "delete from `test`.`roles`  where `id`=$id";


             /*执行查询数据库语句，将刚刚提交的新闻数据查询出来用变量接住*/
             mysqli_query($link,$sql);

             /*判断影响行数*/
             $rows = mysqli_affected_rows($link);

             if($rows>0){echo "<script>alert('删除成功');location.href='index.php?c=role&a=list&admin=1'</script>";}
             die;
        }
/*操作删除*/





/*批量删除数据*/
        if(!empty($_POST['checked'])){
                foreach($_POST['checked'] as $key => $v ){

                        $sql ="delete from `test`.`roles`  where `id`=$v";
                        mysqli_query($link,$sql);
                        $rows= mysqli_affected_rows($link);
                        if($rows>0){
                                echo "<script>alert('所选数据删除成功');location.href='index.php?c=role&a=list&admin=1'</script>";
                       }
                }
                //print_r($_POST);die;
        }else{
               echo "<script>alert('您没有选择任何数据');location.href='index.php?c=role&a=list&admin=1'</script>";
        }

?>